package cn.kgc.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
public class RedisController {
    @Autowired
    private RedisTemplate redisTemplate;

    @GetMapping("/redis/get/{key}")
    public Object get(@PathVariable("key") String key) {
        System.out.println(redisTemplate.opsForValue().get("a"));
        return redisTemplate.opsForValue().get(key);
    }

    @PostMapping("/redis/set/{key}")
    @ResponseBody
    public Object set(@PathVariable("key") String key, @RequestBody Object request) {
        redisTemplate.opsForValue().set(key, request);
        return "set success";
    }

}
